<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>css简化</title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .m10{
                margin: 10px;
            }
            .btn{
                display: inline-block;
                padding: 6px 16px; 
                border: 1px solid #446d88;
                background: #58a linear-gradient(#77a0bb, #58a);
                border-radius: 4px; box-shadow: 0 1px 5px gray;
                color: white;
                text-shadow: 0 -1px 1px #335166;
                font-size: 20px;
                line-height: 30px;
            }
            .btn-simplify1{
                /*优化字体大小，行高*/
                font-size: 125%; /* 假设父级字体为 16px */ 
                line-height: 1.5;

                display: inline-block;
                padding: 6px 16px; 
                border: 1px solid #446d88;
                background: #58a linear-gradient(#77a0bb, #58a);
                border-radius: 4px; box-shadow: 0 1px 5px gray;
                color: white;
                text-shadow: 0 -1px 1px #335166;
            }
            /* 内边距使用em */
            .btn-simplify2{
                display: inline-block;
                padding: .3em .8em; border: 1px solid #446d88; background: #58a linear-gradient(#77a0bb, #58a); border-radius: .2em; box-shadow: 0 .05em .25em gray; color: white; text-shadow: 0 -.05em .05em #335166; font-size: 125%; line-height: 1.5;
            }
            /* 修改背景颜色 */
            .btn-simplify3{
                display: inline-block;
                padding: .3em .8em; border: 1px solid rgba(0,0,0,.1); background: #58a linear-gradient(hsla(0,0%,100%,.2),transparent); border-radius: .2em; box-shadow: 0 .05em .25em rgba(0,0,0,.5); color: white; text-shadow: 0 -.05em .05em rgba(0,0,0,.5); font-size: 125%; line-height: 1.5;
            }
            .btn-simplify3.cancel { background-color: #c00; } 
            .btn-simplify3.ok { background-color: #6b0; }
        </style>
    </head>
    <body>
        <h1>CSS秘密花园： CSS 编码技巧</h1>
        <p>来源:<a href="https://www.w3cplus.com/css3/css-secrets/css-coding-tips.html">https://www.w3cplus.com/css3/css-secrets/css-coding-tips.html</a></p>
        <div class="btn m10">Yes!</div>
        <div class="btn-simplify1 m10">Yes!</div>
        <div class="btn-simplify2 m10">Yes!</div>
        <div class="btn-simplify3 m10">Yes!</div>
        <div class="btn-simplify3 cancel m10">Cancel</div>
        <div class="btn-simplify3 ok m10">Ok</div>
        <script>
        var onLine = navigator.onLine;
        alert('onLine='+onLine);
        // var type = navigator.connection.type;

        // Get an upper bound on the downlink speed of the first network hop
        var max = navigator.connection.downlinkMax;

        function changeHandler(e) {
          // Handle change to connection here.
          alert('网络变化了'+e);
        }

        // Register for event changes.
        navigator.connection.onchange = changeHandler;

        // Alternatively.
        navigator.connection.addEventListener('change', changeHandler);
            // type = navigator.connection.type;
        // alert('type='+type+';onLine='+onLine);
            
        </script>
    </body>
</html>